﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ActiproSoftware.Windows.Controls.Ribbon.Controls;
using Caliburn.PresentationFramework.ApplicationModel;
using XWord.WPF.ApplicationFramework.Extensions;
using ActiproSoftware.Windows.Controls.Docking;
using Caliburn.PresentationFramework.Metadata;
using Luna.WPF.ApplicationFramework;
using Microsoft.Windows.Controls.Ribbon;
namespace XWord.GUI.Views.Fundamental
{
    /// <summary>
    /// Interaction logic for WordTabView.xaml
    /// </summary>
    public partial class ExplorersViewTabView : RibbonTab
    {
        public ExplorersViewTabView()
        {
            InitializeComponent();
        }

        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            //DockingWindow
           
            var element = sender as System.Windows.Controls.CheckBox;
            var presenter = element.DataContext as DockingPresenter;
            
            if (!presenter.IsInitialized && element.IsChecked.Value)
            {
                presenter.Show();
                return;
            }
            var view = presenter.GetView<FrameworkElement>(null);
            var win = view.Parent as DockingWindow;
            if (win == null && element.IsChecked.Value)
            {
                presenter.Show();
                return;
            }
            if (element.IsChecked.Value)
            {
                if (!win.IsOpen) win.Open();
            }
            else
            {
                if (win.IsOpen) win.Close();
            }
            
        }
    }
}
